<nz-card class="m-b-2">
  <div class="common-search-wrap">
    <div class="common-search-forms">
      <div class="common-form-item">
        <label class="common-search-label">机型名称</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="请输入机型名称" [(ngModel)]="seachParams.name" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">所属分类</label>
        <div class="common-search-conrol">
          <nz-select
            nzAllowClear
            nzShowSearch
            nzPlaceHolder="请选择所属分类"
            [(ngModel)]="seachParams.typeId"
          >
            <nz-option *ngFor="let option of classOptions" [nzValue]="option.id" [nzLabel]="option.name"></nz-option>
          </nz-select>
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">状态</label>
        <div class="common-search-conrol">
          <nz-select nzAllowClear nzPlaceHolder="全部" [(ngModel)]="seachParams.status">
            <nz-option nzLabel="启用" nzValue="1"></nz-option>
            <nz-option nzLabel="禁用" nzValue="0"></nz-option>
          </nz-select>
        </div>
      </div>

      <div class="common-form-item">
        <button nz-button nzType="primary" [nzLoading]="tableParams.tableLoading" class="m-r-8" (click)="seachData()">查询</button>
        <button nz-button nzType="default" (click)="resetData()">重置</button>
        <!-- <button nz-button nzType="link" (click)="isCollapse = !isCollapse">
          {{ isCollapse ? '收起' : '展开' }}<i nz-icon [nzType]="isCollapse ? 'up' : 'down'" nzTheme="outline"></i>
        </button> -->
      </div>
    </div>
  </div>
</nz-card>

<nz-card>
  <div class="opera-wrap p-b-10">
    <button nz-button nzType="primary" (click)="addUpdate()">
      <i nz-icon nzType="plus" nzTheme="outline"></i>新增选择机型
    </button>
  </div>

  <!-- Table -->
  <div class="pagination-wrap-position">
    <div class="table-wrap">
      <nz-table
        #basicTable
        nzSize="small"
        nzShowSizeChanger
        nzShowQuickJumper
        nzOuterBordered
        [nzFrontPagination]="false"
        [nzLoadingDelay]="100"
        [nzLoading]="tableParams.tableLoading"
        [nzData]="tableData"
        [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
        [nzTotal]="tableParams.total"
        [nzPageIndex]="tableParams.page"
        [nzPageSize]="tableParams.pageSize"
        [nzShowTotal]="totalTemplate"
        (nzPageIndexChange)="onPageIndexChange($event)"
        (nzPageSizeChange)="onPageSizeChange($event)"
      >
        <thead>
          <tr>
            <th nzAlign="center" nzWidth="120px">ID</th>
            <th nzAlign="center">机型名称</th>
            <th nzAlign="center">选择分类</th>
            <th nzAlign="center">状态</th>
            <th nzAlign="center">排序</th>
            <th nzAlign="center">更新时间</th>
            <th nzAlign="center">操作</th>
          </tr>
        </thead>

        <tbody>
          <tr *ngFor="let data of basicTable.data; let index = index;">
            <td nzAlign="center">{{ data.id }}</td>
            <td nzAlign="center">{{ data.modelName || '-' }}</td>
            <td nzAlign="center">{{ data.typeName || '-' }}</td>
            <td nzAlign="center">
              <span [ngStyle]="{'color': data.status == 0 ? '#F56C6C' : '#67C23A'}">
                {{ data.status == 0 ? '禁用' : data.status == 1 ? '启用' : '-' }}
              </span>
            </td>
            <td nzAlign="center">{{ (data.sort || data.sort == 0) ? data.sort : '-' }}</td>
            <td nzAlign="center">{{ data.updateTime || '-' }}</td>
            <!-- 操作 -->
            <td nzAlign="center">
              <button nz-button nzType="link" (click)="addUpdate(data)">编辑</button>
              <a
                nz-button
                nzType="link"
                nzDanger
                nz-popconfirm
                nzPopconfirmTitle="确认删除?"
                [nzIcon]="iconTpl"
                (nzOnConfirm)="deleteItem(data)">
                删除
              </a>
              <ng-template #iconTpl>
                <i nz-icon nzType="question-circle-o" style="color: red;"></i>
              </ng-template>
            </td>
          </tr>
        </tbody>
      </nz-table>

      <!-- 分页template -->
      <ng-template #totalTemplate let-total>共有 {{ tableParams.total }} 条</ng-template>
    </div>
  </div>
</nz-card>